package com.stars.home.activity

import android.os.Bundle
import android.view.View
import com.hwangjr.rxbus.annotation.Subscribe
import com.hwangjr.rxbus.annotation.Tag
import com.qmuiteam.qmui.kotlin.onClick
import com.stars.home.R
import com.stars.home.base.MBActivity
import com.stars.home.config.ConfigRx
import com.stars.home.databinding.ActivityApplyBinding
import com.stars.home.inte.ChoiceData
import com.stars.home.model.bean.ChoseBankBean
import com.stars.home.utils.time.PopuChosePayToUtils
import com.stars.home.vmodel.ApplyVModel

/**
 *on 2022/9/23
 */
class ApplyActivity: MBActivity<ApplyVModel, ActivityApplyBinding>() {

    override fun init(savedInstanceState: Bundle?) {
        super.init(savedInstanceState)
         vm.money.value=intent.extras?.getString("money")

        vm.getRate()

    }

    override fun listeners() {
        super.listeners()
        binding.imgSure.onClick {
            if(vm.isRead.value==0){
                binding.imgSure.setImageResource(R.drawable.me_read_on)
                vm.isRead.value = 1
            }else{
                binding.imgSure.setImageResource(R.drawable.me_read_off)
                vm.isRead.value = 0
            }
        }
        binding.llSure.onClick {
            if(vm.isRead.value==0){
                binding.imgSure.setImageResource(R.drawable.me_read_on)
                vm.isRead.value = 1
            }else{
                binding.imgSure.setImageResource(R.drawable.me_read_off)
                vm.isRead.value = 0
            }
        }



        binding.llChose.onClick {
            PopuChosePayToUtils.show(context(),binding.llChose,object : ChoiceData {
                override fun onRestuse(id: String?) {

                }

            })
        }
    }
    override fun vmClass(): Class<ApplyVModel> {
        return ApplyVModel::class.java
    }
    override fun binding(): ActivityApplyBinding {
       return ActivityApplyBinding.inflate(layoutInflater)
    }

    override fun title(): String? {
        return "提现"
    }

    override val isRxbus: Boolean
        get() = true

    @Subscribe(tags = [Tag(ConfigRx.CHOSE_BANK)])
    fun setChoseBank(bean: ChoseBankBean) {
        if(null!=bean){
            vm.type="3"
            vm.isShow.value=true
            vm.bankId=bean.id
            binding.imgTips.setImageResource(R.drawable.me_bank)

            var bankName=bean.card
            var s1=bankName?.subSequence(0,3)
            var s2=bankName?.subSequence(bankName.length-4,bankName.length)
            var s= "$s1 **** $s2"
            binding.tvTips.text = "银行卡($s)"

        }

    }
}
